//
//  DispatchInfoCell.m
//  KuWoCan
//
//  Created by hwd on 17/3/14.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "DispatchInfoCell.h"

@interface DispatchInfoCell ()
NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) UILabel *driverName;
@property (nonatomic, strong) UILabel *driverPhone;
NS_ASSUME_NONNULL_END
@end

@implementation DispatchInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self configCell];
    }
    return self;
}

- (void)configCell
{
    self.driverName = [UILabel new];
    self.driverName.textColor = [UIColor grayColor];
    self.driverName.font = [UIFont systemFontOfSize:14.0];
    [self.contentView addSubview:self.driverName];
    [self.driverName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@15);
        make.height.equalTo(@14);
        make.top.equalTo(@5);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
    }];
    
    self.driverPhone = [UILabel new];
    self.driverPhone.textColor = [UIColor colorWithHexString:@"55aee9"];
    self.driverPhone.font = [UIFont systemFontOfSize:14.0];
    [self.contentView addSubview:self.driverPhone];
    [self.driverPhone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.driverName.mas_right);
        make.height.equalTo(@14);
        make.top.equalTo(self.driverName);
    }];

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toCall)];
    self.driverPhone.userInteractionEnabled = YES;
    [self.driverPhone addGestureRecognizer:tap];
}

- (void)configDriverCellWithDriverName:(NSString *)driverName driverPhone:(NSString *)driverPhone {

    self.driverName.text = [NSString stringWithFormat:@"送货司机：%@", driverName.isEmptyString ? driverName : @""];
    self.driverPhone.text = driverPhone;
}

- (void)toCall
{
    if (_block)
    {
        _block();
    }
}


@end
